package zbl.c0.inter;

/**
 * 		保存所有printf语句中的字符串常量信息
 * @author 朱伯龙
 *
 */

public class StringStack {
	
	private static int top;
	
	private static int MAX_DEPTH = 200;
	
	private String[] strstack;
	
	
	public StringStack(){
		strstack = new String[MAX_DEPTH];		//  非配字符串数组的存储空间
		top = 0;								//	初始化栈顶指针
	}
	
	
	public int getTop(){
		return top;
	}
	
	public void push(String str){
		if(top>=MAX_DEPTH){
			System.out.println("字符串常量栈已满，无法入栈！！！");
			return ;
		}else{
			strstack[top] = new String("");
			strstack[top] = str;
			top++;
		}
	}
	
	public String getStr(int offset){
		if(offset>=top){
			System.out.println("字符串常量栈访问越界！！！");
			return null;
		}else{
			return strstack[offset];
		}
	}
	
}
